package com.serviceprovider.business.module.report.valueobjects;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.sp.transaction.model.TransactionUserAmount;
import com.serviceprovider.business.module.user.model.impl.User;

public class TransactionUserAmountVO {
    private Integer amount;
    private Integer id;
    private String  payeeName;
    private User    user;

    public TransactionUserAmountVO() {}

    public TransactionUserAmountVO(TransactionUserAmount transUserAmount) {
        this.id     = transUserAmount.getId();
        this.amount = transUserAmount.getAmount();
        this.user   = transUserAmount.getUser();

        if (transUserAmount.getUser() != null) {
            this.payeeName = transUserAmount.getUser().getFirstName() + " " + transUserAmount.getUser().getLastName();
        }
    }

    @Override
    public boolean equals(Object obj) {
        if ((obj == null) ||!(obj instanceof TransactionUserAmountVO)) {
            return false;
        }

        TransactionUserAmountVO b  = (TransactionUserAmountVO) obj;
        boolean                 eq = ((id == null) && (b.id == null)) || ((id != null) && id.equals(b.id));

        if (!eq) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        return (id != null)
               ? id.hashCode()
               : 0;
    }

    public Integer getId() {
        return id;
    }

    public Integer getAmount() {
        return amount;
    }

    public String getPayeeName() {
        return payeeName;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setPayeeName(String payeeName) {
        this.payeeName = payeeName;
    }

    public Integer getUserId() {
        return getUser().getId();
    }

    public User getUser() {
        return user;
    }
}



